import { Model } from 'pinia-orm';
import { Attr, Str, Uid, Num, Bool, HasOne, HasMany, BelongsTo, HasManyBy, BelongsToMany, MorphOne,
  MorphTo, MorphMany, MorphToMany, OnDelete
  } from 'pinia-orm/decorators';
import { useAxiosRepo } from '@pinia-orm/axios';
import { useAppConfig } from '@vben/hooks';
import type { WechatpayTransaction, WechatpayTransactionResponse } from '../../views/uctoo/wechatpay_transaction/types.js';
//#region Human-Code Preservation

//#endregion Human-Code Preservation

const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

export class uctoo_wechatpay_transaction extends Model {
  static override entity = 'uctoo_wechatpay_transaction'

@Uid() declare id: string 
@Str('') declare notify_id: string 
@Str('') declare transaction_id: string 
@Str('') declare mchid: string 
@Str('') declare appid: string 
@Str('') declare out_trade_no: string 
@Str('') declare trade_state: string 
@Str('') declare trade_state_desc: string 
@Str('') declare bank_type: string 
@Str('') declare trade_type: string 
@Attr('') declare success_time: string 
@Str('') declare attach: string | null
@Str('') declare payer: string 
@Str('') declare amount: string 
@Str('') declare scene_info: string | null
@Str('') declare promotion_detail: string | null
@Str('') declare is_subscribe: string | null
@Attr('') declare create_time: string 
@Str('') declare resource_type: string | null
@Str('') declare event_type: string | null
@Str('') declare resource_algorithm: string | null
@Str('') declare resource_ciphertext: string | null
@Str('') declare resource_nonce: string | null
@Str('') declare resource_original_type: string | null
@Str('') declare resource_associated_data: string | null
@Str('') declare summary: string | null
@Uid() declare creator: string | null
@Attr('') declare created_at: string 
@Attr('') declare updated_at: string 
@Attr('') declare deleted_at: string | null


  static override config = {
    axiosApi: {
        actions: {
            getuctooWechatpayTransactionList(page: number, pageSize: number, searchParams?: any){
                return useAxiosRepo(uctoo_wechatpay_transaction).api().get(`/uctoo/wechatpay_transaction/${pageSize}/${page}`, {
                  params: searchParams,
                  headers: { 'Content-Type': 'application/json;charset=utf-8',
                          'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                  },
                  baseURL: apiURL,
                  dataKey: 'wechatpayTransactions'
                })
            },
            getuctooWechatpayTransaction(id: string){
              return useAxiosRepo(uctoo_wechatpay_transaction).api().get(`/uctoo/wechatpay_transaction/${id}`, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            adductooWechatpayTransaction(data: Partial<WechatpayTransaction>){
              return useAxiosRepo(uctoo_wechatpay_transaction).api().post('/uctoo/wechatpay_transaction/add', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            edituctooWechatpayTransaction(data: any){
              return useAxiosRepo(uctoo_wechatpay_transaction).api().post('/uctoo/wechatpay_transaction/edit', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            deleteuctooWechatpayTransaction(data: any){
              return useAxiosRepo(uctoo_wechatpay_transaction).api().post('/uctoo/wechatpay_transaction/del', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },

//#region Human-Code Preservation
payTransactionsJSAPI(data: any){ //not save store
              return useAxiosRepo(uctoo_wechatpay_transaction).api().post('/uctoo/wechatpay_transaction/payTransactionsJSAPI', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
                save: false,
              })
            },
            payTransactionsH5(data: any){  //not save store
              return useAxiosRepo(uctoo_wechatpay_transaction).api().post('/uctoo/wechatpay_transaction/payTransactionsH5', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
                save: false,
              })
            },
//#endregion Human-Code Preservation
        } 
    }
  }
}
